import React, { useEffect, useState } from 'react'
import { Badge, Card, Descriptions,Button } from 'antd';
import { getHosListDetailRequest } from '@/api/hospital/hospitalList';
import { Navigate, useNavigate, useParams } from 'react-router-dom';
import { BookingRule, getHosListDetailReturnType, getHosListReturnContentItemType } from '@/api/hospital/model/hospitalListType';

export default function Hospitalshow() {
    //编程式路由
    const navigate = useNavigate()
    //保存医院详情数据
    const [detail,setDetial] = useState<getHosListDetailReturnType>({})
    const {id} = useParams()
    useEffect(() => {
        const getHosListDetail = async () => {
            const re = await getHosListDetailRequest(id as string)
            setDetial(re)
        }
        getHosListDetail()
    })
    return (
        <Card>
            <Descriptions title="基本信息" bordered column={2}>
                <Descriptions.Item label="医院名称">{(detail.hospital as getHosListReturnContentItemType)?.hosname}</Descriptions.Item>
                <Descriptions.Item label="医院logo">
                {(detail.hospital as getHosListReturnContentItemType)?
                (<img width={200} src={`data:image/jpeg;base64,${(detail.hospital as getHosListReturnContentItemType)?.logoData}`} alt="" />):
                ('')
                }
                </Descriptions.Item>
                <Descriptions.Item label="医院编码">{(detail.hospital as getHosListReturnContentItemType)?.hoscode}</Descriptions.Item>
                <Descriptions.Item label="医院地址">{(detail.hospital as getHosListReturnContentItemType)?.param.fullAddress}</Descriptions.Item>
                <Descriptions.Item label="坐车路线" span={2}>{(detail.hospital as getHosListReturnContentItemType)?.route}</Descriptions.Item>
                <Descriptions.Item label="医院简介" span={2}>{(detail.hospital as getHosListReturnContentItemType)?.intro}</Descriptions.Item>
            </Descriptions>
            <Descriptions title="预约规则信息" bordered column={2} style={{marginTop:"20px"}}>
                <Descriptions.Item label="预约周期">{(detail.bookingRule as BookingRule)?.cycle}</Descriptions.Item>
                <Descriptions.Item label="放号时间">{(detail.bookingRule as BookingRule)?.releaseTime}</Descriptions.Item>
                <Descriptions.Item label="停挂时间">{(detail.bookingRule as BookingRule)?.stopTime}</Descriptions.Item>
                <Descriptions.Item label="退号时间">{(detail.bookingRule as BookingRule)?.quitTime}</Descriptions.Item>
                <Descriptions.Item label="预约规则" span={2}>{(detail.bookingRule as BookingRule)?.rule}</Descriptions.Item>
            </Descriptions>
            <Button style={{marginTop:"20px"}} onClick={() => {navigate(-1)}}>返回</Button>
        </Card>
    )
}
